package com.turing.data.engine.utils;

/**
 * @ClassName regexUtil
 * @Description: TODO
 * @Author: fz
 * @Date 2020/12/3
 * @Version V1.0
 **/
public class RegexSoftUtil {

    public static String regexRelace(String element) {

        element = element.replaceAll("[零一二三四五六七八九十]、", "").replaceAll("、", "")
                .replaceAll("其中:", "").replaceAll("减:", "").replaceAll("加:", "").replaceAll(":", "")
        /*.replaceAll ( "\\(.*\\)","" )*/;
        int start1 = element.indexOf("（");
        int start2 = element.indexOf("(");
        int end1 = element.indexOf("）");
        int end2 = element.indexOf(")");
        int start = 0;
        int end = 0;
        if (start1 != -1) {
            start = start1;
        }
        if (start2 != -1) {
            start = start2;
        }
        if (end1 != -1) {
            end = end1;
        }
        if (end2 != -1) {
            end = end2;
        }
        //System.out.println ( "start"+start+"end"+end+"start1"+start1+"end1"+end1+"start2"+start2+"end2"+end2 );
        if ((start != -1 && end != -1) && (start != 0 && end != 0) && start < end) {
            String split = element.substring(start, end + 1);
            //System.out.println ( element.indexOf ( split ) );
            //System.out.println ( "split"+split );
            element = element.replace(split, "");
            //System.out.println ( element );
        }
        return element;
    }

    public static String regexSoftRelace(String element) {

        element = element.replaceAll("[零一二三四五六七八九十]、", "").replaceAll("、", "")
                .replaceAll("减:", "").replaceAll("加:", "").replaceAll("加:", "").replaceAll(":", "");
        int start1 = element.indexOf("（");
        int start2 = element.indexOf("(");
        int end1 = element.indexOf("）");
        int end2 = element.indexOf(")");
        int start = 0;
        int end = 0;
        if (start1 != -1) {
            start = start1;
        }
        if (start2 != -1) {
            start = start2;
        }
        if (end1 != -1) {
            end = end1;
        }
        if (end2 != -1) {
            end = end2;
        }
        if ((start != -1 && end != -1) && (start != 0 && end != 0) && start < end) {
            String split = element.substring(start, end + 1);
            element = element.replace(split, "");
        }
        return element;
    }

    public static Boolean filterIneffectiveTableHeaderAlias(String tableHeader) {


        if (tableHeader.contains("注释")) {

            return true;
        }

        if (tableHeader.contains("序号")) {

            return true;
        }

        if (tableHeader.contains("行次")) {

            return true;
        }

        if (tableHeader.contains("附注")) {

            return true;
        }

        return false;
    }

}
